// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ------------------------------------------------------------------
// Modification history:
// feature: Code style modification
// ------------------------------------------------------------------

#ifndef _EDDS_TOPIC_CONTENTFILTERUTILS_HPP_
#define _EDDS_TOPIC_CONTENTFILTERUTILS_HPP_

#include <array>
#include <cstddef>
#include <cstdint>

#include <xmlparser/attributes/XMLRTPSParticipantAllocationAttributes.hpp>
#include <ertps/rtps/common/CacheChange.h>

namespace evbs {
namespace ertps {
namespace rtps {
namespace ContentFilterUtils {

/**
 * Compute a filter signature according to RTPS 2.5 section 9.6.4.1
 *
 * @param [in]  filter_property   Filtering discovery information from which to compute the filter signature.
 * @param [out] filter_signature  Filter signature.
 */
void compute_signature(const vbsutil::xmlparser::ContentFilterProperty& filter_property,
                       std::array<uint8_t, 16>& filter_signature);

bool check_filter_signature(const CacheChange_t& change, const std::array<uint8_t, 16>& filter_signature,
                            bool& filter_result);

}  // namespace ContentFilterUtils
}  // namespace rtps
}  // namespace ertps
}  // namespace evbs

#endif  // _EDDS_TOPIC_CONTENTFILTERUTILS_HPP_
